home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / NeoIntroPP3.0 folder / PowerPlant / NeoBench / Source / CRawText.cp < prev   
Encoding:
Text File  |  1994-07-18  |  2.0 KB  |  59 lines  |  [TEXT/MMCC]

  1. /**********************************************************************
  2.  CRawText.cp
  3.  
  4.                      A Pane containing a text string
  5.  
  6.    This is a text string that can be left justified,  center justified,
  7.    or right justified.    For now,  we can just set it LEFT justified.
  8.  
  9.    The pane's size will be changed depending on the text size.   For
  10.    instance,  when the text is LEFT justified,  the RIGHT side of the
  11.    pane will move out (or in) to just fit the text to be displayed.
  12.  
  13. **********************************************************************/
  14.  
  15. #include "NeoTypes.h"
  16. #include "LView.h"
  17. #include "CRawText.h"
  18. #include "NeoBench.h"
  19. #include <time.h>
  20. #include <stdio.h>
  21.  
  22. /**********************************************************************
  23.  
  24. **********************************************************************/
  25. CRawText::CRawText(LView *aSuperView, ConstStr255Param aText, const short aX, const short aY, const short aWidth, const short aHeight)
  26.     : LCaption()
  27. {
  28.     PutInside(aSuperView);
  29.     SetDescriptor(aText);
  30.     ResizeFrameTo(aWidth, aHeight, FALSE);
  31.     PlaceInSuperImageAt(aX, aY, FALSE);
  32. }
  33.  
  34. /**********************************************************************
  35.  
  36. **********************************************************************/
  37. CTimeText::CTimeText(LView *aSuperView, ConstStr255Param aText, const short aX, const short aY, const short aWidth, const short aHeight)
  38.     : CRawText(aSuperView, aText, aX, aY, aWidth, aHeight)
  39. {
  40. }
  41.  
  42. /*********************************************************************
  43.     aValue is microseconds of time.
  44.  
  45. *********************************************************************/
  46. void CTimeText::SetValue(Int32 aValue)
  47. {
  48.     Str255            string;
  49.  
  50.     unsigned long    value    = (unsigned long)aValue;
  51.     unsigned long    thous    = ((value % 1000000) / 100);    // get thousandths of seconds
  52.     unsigned long    secs    = ((value / 1000000) % 60);        // get seconds
  53.     unsigned long    mins    = (value / (1000000 * 60));        // get minutes
  54.  
  55.     sprintf((char *)&string[1], "%2.0lu:%2.2lu.%4.4lu", mins, secs, thous);
  56.     string[0] = 11;
  57.     SetDescriptor(string);
  58. }
  59.